package com.cxyjy.cfyuiapi.service.impl;

import com.cxyjy.cfyuiapi.service.QueryTaskQueueService;
import com.cxyjy.common.util.JRequestUtil;
import com.cxyjy.common.util.JResponse;
import com.cxyjy.common.util.ResultUtil;
import org.springframework.stereotype.Service;

import java.io.IOException;

import static com.cxyjy.common.constants.CfyuiConstants.PROMPT_URL;

@Service("QueryTaskQueueService")
public class QueryTaskQueueServiceImpl implements QueryTaskQueueService {
    /**
     * 调用ComfyUI接口 GET /prompt
     * 获取服务器当前剩余任务列队的数量
     * @return example:
     * {
     *   "exec_info": {
     *     "queue_remaining": 1
     *   }
     * }
     * @throws IOException
     */
    @Override
    public JResponse QueryTaskQueue() throws IOException {
        return ResultUtil.success(JRequestUtil.sendGetRequest(PROMPT_URL, null));
    }
}
